import 'package:aio/aio.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:app/generated/app_strings.dart';
import 'package:app/src/http/bean/wroks/contract_bean.dart';
import 'package:app/src/http/bean/wroks/receipt_bean.dart';
import 'package:app/src/ui/route/works/public/items/ui_base.dart';
import 'package:app/src/ui/route/works/public/items/ui_card.dart';

///开票审核，开票信息
class UiReceiptapplyInfo {
  ///data 信息
  ///oldData 历史信息
  ///IsApproval 是否已经审核
  static Widget build(BuildContext context, ReceiptBean? data,
      ReceiptBean? oldData, bool IsApproval,
      {String? title}) {
    List<Widget> children = [];
    if (StringUtils.isEmpty(title)) {
      title = AppStrings.of(context).InvoiceInformation; //开票信息
    }
    children.add(UiBase.title(context, title)); //标题
    children.add(UiBase.item(context, AppStrings.of(context).ReceiptCode,
        data?.ReceiptCode, oldData?.ReceiptCode)); //申请单号
    // children.add(UiBase.item(context, AppStrings.of(context).ReceiptCode2,
    //     data?.ReceiptCode, oldData?.ReceiptCode)); //发票单据号（或申请单号）
    if (IsApproval) {
      //已审核
      children.add(UiBase.item(context, AppStrings.of(context).PersonName,
          data?.PersonName, oldData?.PersonName)); //申请人
      children.add(UiBase.item(context, AppStrings.of(context).AddDate5,
          data?.AddDate, oldData?.AddDate)); //申请日期
      children.add(UiBase.item(context, AppStrings.of(context).CompanySh,
          data?.CompanySh, oldData?.CompanySh)); //纳税人识别号
      children.add(UiBase.item(context, AppStrings.of(context).CompanyAddress,
          data?.CompanyAddress, oldData?.CompanyAddress)); //地址电话
      children.add(UiBase.item(context, AppStrings.of(context).CompanyBank,
          data?.CompanyBank, oldData?.CompanyBank)); //开户行及电话
    }
    children.add(UiBase.item(context, AppStrings.of(context).ContractCode,
        data?.ContractCode, oldData?.ContractCode)); //合同编号
    children.add(UiBase.item(context, AppStrings.of(context).OutCode,
        data?.OutCode, oldData?.OutCode)); //合同外部编号
    children.add(UiBase.item(context, AppStrings.of(context).ProjectName,
        data?.ProjectName, oldData?.ProjectName)); //项目名称
    children.add(UiBase.item(context, AppStrings.of(context).CustomerName,
        data?.CustomerName, oldData?.CustomerName)); //客户名称
    children.add(UiBase.item(context, AppStrings.of(context).CustomerCode,
        data?.CustomerCode, oldData?.CustomerCode)); //客户编号
    children.add(UiBase.item(context, AppStrings.of(context).ReceiptTitle,
        data?.ReceiptTitle, oldData?.ReceiptTitle)); //发票抬头
    children.add(UiBase.item(context, AppStrings.of(context).ReceiptType,
        data?.ReceiptType, oldData?.ReceiptType)); //发票类型
    children.add(UiBase.item(
        context,
        AppStrings.of(context).ReceiptAmount1_2,
        data?.ReceiptAmount1,
        oldData?.ReceiptAmount1)); //已申请金额；fixme 显示已申请的，不显示已开
    children.add(UiBase.item(
        context,
        AppStrings.of(context).ReceiptAmount2_2,
        data?.ReceiptAmount2,
        oldData?.ReceiptAmount2)); //可申请金额；fixme 显示已申请的，不显示已开
    children.add(UiBase.item(context, AppStrings.of(context).Amount5,
        data?.Amount, oldData?.Amount)); //申请金额； fixme 显示已申请的，不显示已开
    children.add(UiBase.item(context, AppStrings.of(context).JinShuiCode,
        data?.JinShuiCode, oldData?.JinShuiCode)); //发票号
    children.add(UiBase.item(context, AppStrings.of(context).TaxRate2,
        data?.TaxRate, oldData?.TaxRate)); //税率
    children.add(UiBase.item(
        context, AppStrings.of(context).Tax, data?.Tax, oldData?.Tax)); //税额
    children.add(UiBase.item(context, AppStrings.of(context).ReceiptAmount3,
        data?.ReceiptAmount3, oldData?.ReceiptAmount3)); //不含税金额
    var column = UiBase.column(context, children);
    var card = UiCard.build(context, column);
    return card;
  }
}
